package com.airnews.ticket.net;

import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import com.airnews.ticket.model.AirEXPaymentResult;
import com.airnews.ticket.model.CabinItem;
import com.airnews.ticket.model.CabinPolicy;
import com.airnews.ticket.model.ChangeDateData;
import com.airnews.ticket.model.DesUserOfficeSign;
import com.airnews.ticket.model.Flight;
import com.airnews.ticket.model.FlightInfo;
import com.airnews.ticket.model.FlightOrder;
import com.airnews.ticket.model.FlightRestrict;
import com.airnews.ticket.model.ItineraryInfo;
import com.airnews.ticket.model.MileagerInfo;
import com.airnews.ticket.model.OrderInfo;
import com.airnews.ticket.model.OrderInfoResult;
import com.airnews.ticket.model.SearchFlight;
import com.airnews.ticket.model.SearchOrder;
import com.airnews.ticket.model.TotalOrderInfoResult;
import com.airnews.ticket.model.UserResponseResult;
import com.airnews.ticket.model.VersionInfo;
import com.airnews.ticket.net.type.RequestCreditCard;
import com.airnews.ticket.net.type.RequestMileagerInfo;
import com.airnews.ticket.util.Constants;
import com.airnews.ticket.util.DESedeUtil;
import com.airnews.ticket.util.DateUtil;

public class WebAccessor {
//	//方法名称.
//	private static final String METHOD_NAME = "GetFlightInfo";
//	private static final String SOAP_ACTION = Constants.NAMESPACE + METHOD_NAME;
//	private static final String req_url = "http://test148.airnews.com/ASBE/ASFlightInterface.asmx";
	
	private static String userSign = "";
    
	private static String OfficeSign = "";
    
    public static DesUserOfficeSign buildDesUserOfficeSign(String userIdLogin,String userPwd) {
    	DesUserOfficeSign ds = new DesUserOfficeSign();
    	//平台编码
        String ASID = Constants.ASID + Constants.OfficeID;
        //密钥
        String SecretKey = Constants.SecretKey;
        //加密向量
        String IVS = Constants.IVS;
        //时间戳
        String TimeStamp = DateUtil.getDateTime();
        String userSign = userIdLogin + "|" + userPwd+ "|" + TimeStamp;
        
        String officeSign = ASID + SecretKey + TimeStamp;
        try {
        	//将UserSign进行加密
			userSign = DESedeUtil.encrypt(userSign, SecretKey, IVS);
	        //将OfficeSign进行加密
			officeSign = DESedeUtil.encrypt(officeSign, SecretKey, IVS);
            ds.setOfficeSign(officeSign);
            ds.setUserSign(userSign);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ds;
    }
    
	public static Flight  searchFlight(Context c,SearchFlight flight) {  
		final String METHOD_NAME = "GetFlightInfo";
		final String SOAP_ACTION = Constants.NAMESPACE + METHOD_NAME;
		final String req_url = "http://asbe.airnews.com/ASFlightInterface.asmx";
		
       // 指定WebService的命名空间和调用的方法名  
       SoapObject rpc = new SoapObject(Constants.NAMESPACE, METHOD_NAME);  
       long startTime = System.currentTimeMillis();
       rpc.addProperty("ASID", Constants.ASID + Constants.OfficeID);
       rpc.addProperty("CPriority", 0);
       rpc.addProperty("TimeStamp",DateUtil.getDateTime());
       rpc.addProperty("OfficeID", Constants.OfficeID);
       rpc.addProperty("PIN", "123456");
		
       rpc.addProperty("Departure", flight.departure);
       rpc.addProperty("Arrival", flight.arrival);
       rpc.addProperty("DepartDate", flight.departureDate);
       rpc.addProperty("Airline", flight.airline);
       rpc.addProperty("FlightNumber", "");
       rpc.addProperty("PlaneType", "");
       rpc.addProperty("isDirect", "1");
       rpc.addProperty("OrderBy", "date");
       
       Log.i("出发地", flight.departure);
       Log.i("到达地", flight.arrival);
       Log.i("出发时间", flight.departureDate);
       Log.i("ASID", Constants.ASID);
       Log.i("OfficeID", Constants.OfficeID);
       
       // 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本  
       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);  
 
       envelope.bodyOut = rpc;  
       // 设置是否调用的是dotNet开发的WebService  
       envelope.dotNet = true;  
       // 等价于envelope.bodyOut = rpc;  
       envelope.setOutputSoapObject(rpc);  
 
       HttpTransportSE transport = new HttpTransportSE(req_url);  
 
       try {  
           // 调用WebService  
           transport.call(SOAP_ACTION, envelope);  
       } catch (Exception e) {  
           Flight fly = new Flight();
           fly.message ="无法正常连接到网络，查询失败，请设置好网络连接！";
           fly.resultcode = "-1000";
           return fly;
       }  
 
       // 获取返回的数据  
       SoapObject result = (SoapObject) envelope.bodyIn;  
	   System.out.println("完成查询!共用时[" + (System.currentTimeMillis() - startTime)/1000 + "秒]");

       Log.i("result",result.toString());
       // 获取返回的结果  
       //解析返回结果
       Flight fly = parseFlightInfo(result);
       return fly;
   }
 

    //解析返回结果
	private static Flight parseFlightInfo(SoapObject result)
	{
		long startTime = System.currentTimeMillis();
		Flight fly = new Flight();
		
		if(result==null)
		{
			return null;
		}
		int propertyCount=result.getPropertyCount();
		for(int i=0;i<propertyCount;i++)
		{
			SoapObject flightInfo=(SoapObject)result.getProperty(i);
			int flightInfoCount=flightInfo.getPropertyCount();
			//成功返回
			if(flightInfo.getProperty("Result").toString().equals("0"))
			{
				fly.resultcode = "0";
				//有符合条件的结果
				if(flightInfoCount>2)
				{
					SoapObject asFlightInfos=(SoapObject)flightInfo.getProperty("ASFlightInfos");
					int flightPolicyCount=asFlightInfos.getPropertyCount();
					for(int j=0;j<flightPolicyCount;j++)
					{
						//取得航线信息
						SoapObject flightPolicy=(SoapObject)asFlightInfos.getProperty(j);
						FlightInfo dto = new FlightInfo();
						String airline=flightPolicy.getProperty("Airline").toString();
						String flightId=flightPolicy.getProperty("FlightID").toString();
						String flightNo=flightPolicy.getProperty("FlightNo").toString();
						String departure=flightPolicy.getProperty("Departure").toString();
						String departureTime=flightPolicy.getProperty("DepartureTime").toString();
						String arrival=flightPolicy.getProperty("Arrival").toString();
						String arrivalTime=flightPolicy.getProperty("ArrivalTime").toString();
						String stopNo=flightPolicy.getProperty("StopNo").toString();
						String isFood=flightPolicy.getProperty("IsFood").toString();
						String isCodeShare=flightPolicy.getProperty("IsCodeShare").toString();
						String planeType=flightPolicy.getProperty("PlaneType").toString();
						String carrier=flightPolicy.getProperty("Carrier").toString();
						String specialCabin=flightPolicy.getProperty("SpecialCabin").toString();
						String mPrice=flightPolicy.getProperty("MPrice").toString();
						dto.airline = airline;
						dto.flightId = flightId;
						dto.flightNo = flightNo;
						dto.departure = departure;
						dto.departureTime = departureTime;
						dto.arrival = arrival;
						dto.arrivalTime = arrivalTime;
						dto.stopNo = Integer.valueOf(stopNo);
						dto.isFood = Integer.valueOf(isFood);
						dto.isCodeShare = Integer.valueOf(isCodeShare);
						dto.planeType = planeType;
						dto.carrier = carrier;
						dto.specialCabin = specialCabin;
						dto.mPrice = mPrice;
						
						//插入数据到航线信息表
						//long flightID=mFlightInfoDB.insertFlightPolicy(airline, flightNo, departure, departureTime, arrival, arrivalTime, stopNo, isFood, isCodeShare, planeType, carrier, specialCabin);
						//取得每架飞机舱位信息
						SoapObject flightCabins=(SoapObject)flightPolicy.getProperty("ASFlightCabins");
						int flightCabinCount=flightCabins.getPropertyCount();
						for(int k=0;k<flightCabinCount;k++)
						{
							SoapObject flightCabin=(SoapObject)flightCabins.getProperty(k);
							CabinItem cabinItem = new CabinItem();
							String cabin=flightCabin.getProperty("Cabin").toString();
							String seat=flightCabin.getProperty("Seat").toString();
							String discount=flightCabin.getProperty("Discount").toString();
							String cabinPrice=flightCabin.getProperty("CabinPrice").toString();
							String baseCabin=flightCabin.getProperty("BaseCabin").toString();
							//插入数据到舱位信息表
							//long cabinID=mFlightInfoDB.insertFlightCabin(flightID, cabin, seat, discount, cabinPrice, baseCabin);
							//取得最优政策
//							SoapObject flightCabinPolicys=(SoapObject)flightCabin.getProperty("FlightCabinPolicys");
//							int flightCabinPolicyCount=flightCabinPolicys.getPropertyCount();
//							for(int m=0;m<flightCabinPolicyCount;m++)
//							{
//								SoapObject flightCabinPolicy=(SoapObject)flightCabinPolicys.getProperty(m);
								String airPolicyID=flightCabin.getProperty("AirPolicyID").toString();
								String sPID=flightCabin.getProperty("SPID").toString();
								String price=flightCabin.getProperty("Price").toString();
								String outTicketStartDate=flightCabin.getProperty("OutTicketStartDate").toString();
								String outTicketEndDate=flightCabin.getProperty("OutTicketEndDate").toString();
								String tripType=flightCabin.getProperty("TripType").toString();
								String characterType=flightCabin.getProperty("CharacterType").toString();
								String passengerType=flightCabin.getProperty("PassengerType").toString();
								String ticketType=flightCabin.getProperty("TicketType").toString();
								String policyRule="";//flightCabinPolicy.getProperty("PolicyRule").toString();
								String others=flightCabin.getProperty("Others").toString();
								String serviceTimeStart=flightCabin.getProperty("ServiceTimeStart").toString();
								String z=flightCabin.getProperty("Z").toString();
								String y=flightCabin.getProperty("Y").toString();
								String serviceTimeEnd=flightCabin.getProperty("ServiceTimeEnd").toString();
								String sPSourceType=flightCabin.getProperty("SPSourceType").toString();
								String fuelTax="";//flightCabinPolicy.getProperty("FuelTax").toString();
								String airportTax="";//flightCabinPolicy.getProperty("AirportTax").toString();
								
								cabinItem.cabin = cabin;
								cabinItem.seat = seat;
								cabinItem.discount = discount;
								cabinItem.cabinPrice = cabinPrice;
								cabinItem.baseCabin = baseCabin;
								cabinItem.airPolicyID = airPolicyID;
								cabinItem.sPID = sPID;
								cabinItem.price = price;
								cabinItem.outTicketStartDate = outTicketStartDate;
								cabinItem.outTicketEndDate = outTicketEndDate;
								cabinItem.tripType = tripType;
								cabinItem.characterType = characterType;
								cabinItem.passengerType = passengerType;
								cabinItem.ticketType = ticketType;
								cabinItem.policyRule = policyRule;
								cabinItem.serviceTimeStart = serviceTimeStart;
								cabinItem.z = z;
								cabinItem.y = y;
								cabinItem.serviceTimeEnd = serviceTimeEnd;
								cabinItem.sPSourceType = sPSourceType;
								cabinItem.fuelTax = fuelTax;
								cabinItem.airportTax = airportTax;
								cabinItem.others = others;
								
								dto.cabinItems.add(cabinItem);
								//插入数据到舱位政策信息表
								//long cabinPolicyID=mFlightInfoDB.insertFlightCabinPolicy(cabinID, airPolicyID, sPID, price, outTicketStartDate, outTicketEndDate, tripType, characterType, passengerType, ticketType, policyRule, others, serviceTimeStart, z, y, serviceTimeEnd, sPSourceType, fuelTax, airportTax);								
//							}
						}
						fly.flightInfos.add(dto);
					}
				}
				else
				{
					
				}
			}
			else
			{
				fly.message = flightInfo.getProperty("ErrorDescription").toString();
			}
		}
		System.out.println("完成取数据!共用时[" + (System.currentTimeMillis() - startTime)/1000 + "秒]");

		return fly;
	}
	/**
	 * 功能说明
	 *	根据输入参数获取电子客票、航班与政策信息。
	 *	1) 仅查询电子客票、非代码共享、单程的航班。
	 *	2) 仅提供公布运价、成人政策。
	 *	3) 提供BSP、本电最优政策各一条。
	 *	4) 政策包含出票时限、票规等信息。
	 * @param c
	 * @param flight
	 * @return
	 */
	public static Flight  GetFlightTicket(Context c,SearchFlight flight) {  
		final String METHOD_NAME = "GetFlightTicket";
		final String SOAP_ACTION = Constants.NAMESPACE + METHOD_NAME;
		final String req_url = "http://asbe.airnews.com/ASFlightInterface.asmx";
		
       // 指定WebService的命名空间和调用的方法名  
       SoapObject rpc = new SoapObject(Constants.NAMESPACE, METHOD_NAME);  
       long startTime = System.currentTimeMillis();
       rpc.addProperty("ASID", Constants.ASID + Constants.OfficeID);
       rpc.addProperty("CPriority", 0);
       rpc.addProperty("TimeStamp",DateUtil.getDateTime());
       rpc.addProperty("OfficeID", Constants.OfficeID);
       rpc.addProperty("PIN", "123456");
		
       rpc.addProperty("Departure", flight.departure);
       rpc.addProperty("Arrival", flight.arrival);
       rpc.addProperty("DepartDate", flight.departureDate);
       rpc.addProperty("Airline", flight.airline);
       rpc.addProperty("FlightNumber", "");
       rpc.addProperty("Cabin", flight.fclassGrade);
       rpc.addProperty("isDirect", "1");
       rpc.addProperty("OrderBy", "date");
       
       Log.i("出发地", flight.departure);
       Log.i("到达地", flight.arrival);
       Log.i("出发时间", flight.departureDate);
       System.out.println("Airline="+ flight.airline);
       System.out.println("Cabin="+flight.fclassGrade);
       Log.i("ASID", Constants.ASID);
       Log.i("OfficeID", Constants.OfficeID);
       // 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本  
       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);  
 
       envelope.bodyOut = rpc;  
       // 设置是否调用的是dotNet开发的WebService  
       envelope.dotNet = true;  
       // 等价于envelope.bodyOut = rpc;  
       envelope.setOutputSoapObject(rpc);  
 
       HttpTransportSE transport = new HttpTransportSE(req_url);  
 
       try {  
           // 调用WebService  
           transport.call(SOAP_ACTION, envelope);  
       } catch (Exception e) {  
           Flight fly = new Flight();
           fly.message ="无法正常连接到网络，查询失败，请设置好网络连接！";
           fly.resultcode = "-1000";
           return fly;
       }  
 
       // 获取返回的数据  
       SoapObject result = (SoapObject) envelope.bodyIn;  
	   System.out.println("完成查询!共用时[" + (System.currentTimeMillis() - startTime)/1000 + "秒]");

       Log.i("result",result.toString());
       // 获取返回的结果  
       //解析返回结果
       Flight fly = parseLeFlight(result);
       return fly;
   }
	
    //解析返回结果
	private static Flight parseLeFlight(SoapObject result)
	{
		long startTime = System.currentTimeMillis();
		Flight fly = new Flight();
		
		if(result==null)
		{
			return null;
		}
		int propertyCount=result.getPropertyCount();
		for(int i=0;i<propertyCount;i++)
		{
			SoapObject flightInfo=(SoapObject)result.getProperty(i);
			int flightInfoCount=flightInfo.getPropertyCount();
			//成功返回
			if(flightInfo.getProperty("Result").toString().equals("0"))
			{
				fly.resultcode = "0";
				//有符合条件的结果
				if(flightInfoCount>2)
				{
					SoapObject asFlightInfos=(SoapObject)flightInfo.getProperty("LesFlights");
					int flightPolicyCount=asFlightInfos.getPropertyCount();
					for(int j=0;j<flightPolicyCount;j++)
					{
						//取得航线信息
						SoapObject flightPolicy=(SoapObject)asFlightInfos.getProperty(j);
						FlightInfo dto = new FlightInfo();
						String airline=flightPolicy.getProperty("Airline").toString();
						String flightId=flightPolicy.getProperty("FlightID").toString();
						String flightNo=flightPolicy.getProperty("FlightNo").toString();
						String departure=flightPolicy.getProperty("Departure").toString();
						String departureTime=flightPolicy.getProperty("DepartureTime").toString();
						String arrival=flightPolicy.getProperty("Arrival").toString();
						String arrivalTime=flightPolicy.getProperty("ArrivalTime").toString();
						String stopNo=flightPolicy.getProperty("StopNo").toString();
						String isFood=flightPolicy.getProperty("IsFood").toString();
						String isCodeShare=flightPolicy.getProperty("IsCodeShare").toString();
						String planeType=flightPolicy.getProperty("PlaneType").toString();
						String carrier=flightPolicy.getProperty("Carrier").toString();
						String specialCabin=flightPolicy.getProperty("SpecialCabin").toString();
						String mPrice=flightPolicy.getProperty("MPrice").toString();
						dto.airline = airline;
						dto.flightId = flightId;
						dto.flightNo = flightNo;
						dto.departure = departure;
						dto.departureTime = departureTime;
						dto.arrival = arrival;
						dto.arrivalTime = arrivalTime;
						dto.stopNo = Integer.valueOf(stopNo);
						dto.isFood = Integer.valueOf(isFood);
						dto.isCodeShare = Integer.valueOf(isCodeShare);
						dto.planeType = planeType;
						dto.carrier = carrier;
						dto.specialCabin = specialCabin;
						dto.mPrice = mPrice;
						
						//取得每架飞机舱位信息
						SoapObject flightCabins=(SoapObject)flightPolicy.getProperty("FlightTickets");
						int flightCabinCount=flightCabins.getPropertyCount();
						
						for(int k=0;k<flightCabinCount;k++){
							SoapPrimitive flightCabin=(SoapPrimitive)flightCabins.getProperty(k);
							//cabinStr包含舱位代码，折扣，剩余座位数，舱位价格，返利金额，机场建设税，燃油附加税，机票类型。
							String cabinStr = String.valueOf(flightCabin);
							if(cabinStr!=null && cabinStr.length()>0){
								String[] cabArray = cabinStr.split(";");
								String cabin = cabArray[0];
								String discount = cabArray[1];
								String seat = cabArray[2];
								String cabinPrice  = cabArray[3];
								String rebate  = cabArray[4];
								String airportTax  = cabArray[5];
								String fuelTax   = cabArray[6];
								String ticketType  = "";
								CabinItem cabinItem = new CabinItem();
								cabinItem.cabin = cabin;
								cabinItem.seat = seat;
								cabinItem.discount = discount;
								cabinItem.cabinPrice = cabinPrice;
								cabinItem.baseCabin = cabin;
								cabinItem.fuelTax = fuelTax;
								cabinItem.airportTax = airportTax;
								cabinItem.ticketType = ticketType;
								cabinItem.price = cabinPrice;
								cabinItem.ibePayment = rebate;
								dto.cabinFlight = cabin;
								dto.cabinItems.add(cabinItem);
							}
						}
						if(flightCabinCount!=0){
							fly.flightInfos.add(dto);
						}
					}
				}
				else
				{
					
				}
			}
			else
			{
				fly.message = flightInfo.getProperty("ErrorDescription").toString();
			}
		}
		System.out.println("完成取数据!共用时[" + (System.currentTimeMillis() - startTime)/1000 + "秒]");

		return fly;
	}
	
	public static FlightRestrict  getFlightRestrict(Context c,FlightInfo fInfo) {  
		final String METHOD_NAME = "GetFlightRestrict";
		final String SOAP_ACTION = Constants.NAMESPACE + METHOD_NAME;
		final String req_url = "http://asbe.airnews.com/ASFlightInterface.asmx";
		
       // 指定WebService的命名空间和调用的方法名  
       SoapObject rpc = new SoapObject(Constants.NAMESPACE, METHOD_NAME);  
       long startTime = System.currentTimeMillis();
       try{
       rpc.addProperty("ASID", Constants.ASID + Constants.OfficeID);
       rpc.addProperty("CPriority", 0);
       rpc.addProperty("TimeStamp",DateUtil.getDateTime());
       rpc.addProperty("OfficeID", Constants.OfficeID);
       rpc.addProperty("PIN", "123456");
       
//       Log.i("1出发地", fInfo.departure);
//       Log.i("1到达地", fInfo.arrival);
//       System.out.println("航空公司="+fInfo.airline);
//       Log.i("出发时间", fInfo.departureTime);
//       System.out.println("flightNumber="+fInfo.flightNo);
//       System.out.println("fInfo.cabinFlight="+fInfo.cabinFlight);
       
       rpc.addProperty("Departure", fInfo.departure);
       rpc.addProperty("Arrival", fInfo.arrival);
       rpc.addProperty("DepartTime", fInfo.departureTime);
       rpc.addProperty("Airline", fInfo.airline);
       rpc.addProperty("FlightNumber", fInfo.flightNo);
       rpc.addProperty("Cabin", fInfo.cabinFlight);
       } catch(Exception e){
    	   System.out.println("e="+e);
       }
       // 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本  
       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);  
 
       envelope.bodyOut = rpc;  
       // 设置是否调用的是dotNet开发的WebService  
       envelope.dotNet = true;  
       // 等价于envelope.bodyOut = rpc;  
       envelope.setOutputSoapObject(rpc);  
 
       HttpTransportSE transport = new HttpTransportSE(req_url);  
 
       try {  
           // 调用WebService  
           transport.call(SOAP_ACTION, envelope);  
       } catch (Exception e) {  
    	   FlightRestrict fly = new FlightRestrict();
           fly.message ="无法正常连接到网络，查询失败，请设置好网络连接！";
           fly.resultcode = "-1000";
           return fly;
       }  
 
       // 获取返回的数据  
       SoapObject result = (SoapObject) envelope.bodyIn;  
	   System.out.println("完成查询!共用时[" + (System.currentTimeMillis() - startTime)/1000 + "秒]");

       Log.i("result",result.toString());
       // 获取返回的结果  
       //解析返回结果
       FlightRestrict fly = parseFlightRestrict(result);
       return fly;
   }

    //解析返回结果
	private static FlightRestrict parseFlightRestrict(SoapObject result)
	{
		long startTime = System.currentTimeMillis();
		FlightRestrict fly = new FlightRestrict();
		
		if(result==null)
		{
			return null;
		}
		int propertyCount=result.getPropertyCount();
		try{
		for(int i=0;i<propertyCount;i++)
		{
			SoapPrimitive flightInfo=(SoapPrimitive)result.getProperty(i);
			Log.i("flightInfo"+i, String.valueOf(flightInfo));
			fly.airc0 = String.valueOf(flightInfo);
			fly.resultcode = "0";
		}
		}catch(Exception e){
			
		}
		System.out.println("完成取数据!共用时[" + (System.currentTimeMillis() - startTime)/1000 + "秒]");

		return fly;
	}
	
	public static String GenerateOrderNO_Bak(String userIdLogin,String userPwd,DesUserOfficeSign ds) {
		   final String METHOD_NAME = "GenerateOrderNO";
		   final String SOAP_ACTION = Constants.NAMESPACE + METHOD_NAME;
		   final String req_url = "http://asoc.airnews.com/ASOrderV1.asmx";
		   
	        //平台编码00110099
	        String ASID = Constants.ASID + Constants.OfficeID;
	        //时间戳00110001
	        String TimeStamp = DateUtil.getDateTime();
	        
			userSign = ds.getUserSign();
			OfficeSign	= ds.getOfficeSign();
			
			System.out.println("TimeStamp="+TimeStamp);
			System.out.println("userSign="+userSign);
			System.out.println("OfficeSign="+OfficeSign);
	       // 指定WebService的命名空间和调用的方法名  
	       SoapObject rpc = new SoapObject(Constants.NAMESPACE, METHOD_NAME);  
	 
	       rpc.addProperty("ASID", ASID);
	       rpc.addProperty("ASPriority", 0);
	       rpc.addProperty("TimeStamp",TimeStamp);
	       rpc.addProperty("OfficeSign", OfficeSign);
	       rpc.addProperty("UserSign", userSign);
			
	        //生成订单号
	       // 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本  
	       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);  
	 
	       envelope.bodyOut = rpc;  
	       // 设置是否调用的是dotNet开发的WebService  
	       envelope.dotNet = true;  
	       // 等价于envelope.bodyOut = rpc;  
	       envelope.setOutputSoapObject(rpc);  
	 
	       HttpTransportSE transport = new HttpTransportSE(req_url);  
	 
	       try {  
	           // 调用WebService  
	           transport.call(SOAP_ACTION, envelope);  
	       } catch (Exception e) {  
	           e.printStackTrace();  
	       }  
	 
	       // 获取返回的数据  
	       SoapObject result = (SoapObject) envelope.bodyIn;  
	       String orderNO = "";
	       if(result==null)
			{
				return orderNO;
			}
			int propertyCount=result.getPropertyCount();
			for(int i=0;i<propertyCount;i++)
			{
				SoapObject orderNOObject=(SoapObject)result.getProperty(i);
				//成功返回
				if(orderNOObject.getProperty("Ret_Code").toString().equals("0")) {
					orderNO = orderNOObject.getProperty("OrderNO").toString();
				}
					
			}
			System.out.println("orderNO="+orderNO);
	       return orderNO;
	}
	
	public static String GenerateOrderNO(String userIdLogin,String userPwd,DesUserOfficeSign ds) {
		//平台编码00110099
        String ASID = Constants.ASID + Constants.OfficeID;
        //时间戳00110001
        String TimeStamp = DateUtil.getDateTime();
        
		userSign = ds.getUserSign();
		OfficeSign	= ds.getOfficeSign();
		
		String url = "http://asoc.airnews.com/ASOrderV1.asmx";
        StringBuffer sb =  new StringBuffer("");
	    sb.append("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:asoc='http://asoc.airnews.com/'>");
	    sb.append("<soapenv:Header/>")
	    .append("  <soapenv:Body>")
	    .append("     <asoc:GenerateOrderNo>")
	    .append("      <asoc:ASID>" + ASID + "</asoc:ASID>")
	    .append("      <asoc:ASPriority>0</asoc:ASPriority>")
	    .append("      <asoc:TimeStamp>" + TimeStamp + "</asoc:TimeStamp>")
	    .append("      <asoc:UserSign>" + userSign + "</asoc:UserSign>")
	    .append("      <asoc:OfficeSign>" + OfficeSign + " </asoc:OfficeSign>")
	    .append("    </asoc:GenerateOrderNo>")
	    .append("  </soapenv:Body>")
	    .append("</soapenv:Envelope>");
        System.out.println(sb.toString());
        
        String s = BaseAccessor.connectURL(url, sb.toString());
        String orderNO = "";
        String regCode = "";
        try {
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
    		if(doc.length()>0) {
    			regCode = doc.substring(doc.indexOf("<Ret_Code>")+("<Ret_Code>").length(), doc.indexOf("</Ret_Code>"));
    			orderNO = doc.substring(doc.indexOf("<OrderNo>")+("<OrderNo>").length(), doc.indexOf("</OrderNo>"));
    		}
        	Log.i("","Recived:".concat(orderNO).toString());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return orderNO;
		
	}
	public static TotalOrderInfoResult TotalOrderRequest (String xml) {
		TotalOrderInfoResult totalOrderInfoResult = new TotalOrderInfoResult();
		String url = "http://asoc.airnews.com/ASOrderV1.asmx";
//		String url = "http://awp.airnews.com/TotalOrder";
		
		String orderNO = "";
		String flightOrderNOArray = "";
		String itineraryOrderNOArray = "";
		String regCode = "";
		String regMsg = "";
        try {
        	
//        	String reqXml = new String(xml.getBytes("GBK"), System.getProperty("file.encoding"));
//        	Log.i("reqXml", reqXml);
    		String s = BaseAccessor.connectURL(url, xml);
    		Log.i("response xml", s);
    		
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
    		if(doc.length()>0) {
    			regCode = doc.substring(doc.indexOf("<Result>")+("<Result>").length(), doc.indexOf("</Result>"));
    			totalOrderInfoResult.Ret_Code = regCode;
    			regMsg = doc.substring(doc.indexOf("<ErrorDescription>")+("<ErrorDescription>").length(), doc.indexOf("</ErrorDescription>"));
    			totalOrderInfoResult.Ret_Msg = regMsg;
            	Log.i("doc ","Recived:  orderNO : ".concat(orderNO).concat("  regMsg:").concat(regMsg).concat("  ").concat(itineraryOrderNOArray));

    			if("0".equals(regCode)){
	    			orderNO = doc.substring(doc.indexOf("<OrderNo>")+("<OrderNo>").length(), doc.indexOf("</OrderNo>"));
	    			totalOrderInfoResult.OrderNO = orderNO;
	    			flightOrderNOArray = doc.substring(doc.indexOf("<TicketOrderNos>")+("<TicketOrderNos>").length(), doc.indexOf("</TicketOrderNos>"));
	    			flightOrderNOArray = flightOrderNOArray.replace("<string>", "").replace("</string>", ";");
	    			totalOrderInfoResult.FlightOrderNO = flightOrderNOArray.split(";");
	    			try{
		    			itineraryOrderNOArray = doc.substring(doc.indexOf("<ItineraryOrderNos>")+("<ItineraryOrderNos>").length(), doc.indexOf("</ItineraryOrderNos>"));
		    			itineraryOrderNOArray = itineraryOrderNOArray.replace("<string>", "").replace("</string>", ";");
		    			totalOrderInfoResult.ItineraryOrderNO = itineraryOrderNOArray.split(";");
	    			} catch(Exception e){
	    				totalOrderInfoResult.ItineraryOrderNO = null;
	    			}
    			}
    		}
        	Log.i("TotalOrderInfoResult ","Recived:".concat(orderNO).concat("  ").concat(flightOrderNOArray).concat("  ").concat(itineraryOrderNOArray));

        	//Log.i("totalOrderInfoResult ","totalOrderInfoResult:".concat(totalOrderInfoResult.FlightOrderNO[0]).concat("  ").concat(totalOrderInfoResult.FlightOrderNO[1]));
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return totalOrderInfoResult;
	}
	
	public static String passengerInfoManage (String xml) {
		String url = "http://test148.airnews.com/COA/ASMemberCenter.asmx";
		String s = BaseAccessor.connectURL(url, xml);
        try {
        	Log.i("","Recived:".concat(new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"))));
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "";
	}
	
   //取用户认证号码
	public static String createAuthorize(String userIdLogin,String userPwd) {
		//平台编码
        String ASID = Constants.ASID + Constants.OfficeID;
        //时间戳
        String TimeStamp = DateUtil.getDateTime();
        
        String serviceType = "user_login";
        
		DesUserOfficeSign ds = buildDesUserOfficeSign(userIdLogin,userPwd);
		
		userSign = ds.getUserSign();
		OfficeSign	= ds.getOfficeSign();
		
		String url = "http://coa.airnews.com/ASMemberCenter.asmx";
        StringBuffer sb =  new StringBuffer("");
	    sb.append("<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope' xmlns:coa='http://COA.airnew.com'>");
	    sb.append("<soap:Header/>")
	    .append("  <soap:Body>")
	    .append("     <coa:GetAuthorize>")
	    .append("      <coa:ASID>" + ASID + "</coa:ASID>")
	    .append("      <coa:TimeStamp>" + TimeStamp + "</coa:TimeStamp>")
	    .append("      <coa:OfficeSign>" + OfficeSign + " </coa:OfficeSign>")
	    .append("      <coa:UserSign>" + userSign + "</coa:UserSign>")
	    .append("      <coa:ServiceType>" + serviceType + "</coa:ServiceType>")
	    .append("      <coa:Return_URL></coa:Return_URL>")
	    .append("    </coa:GetAuthorize>")
	    .append("  </soap:Body>")
	    .append("</soap:Envelope>");
        System.out.println(sb.toString());
        
        String s = BaseAccessor.connectURL(url, sb.toString());
        String ASToken = "";
        try {
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
    		if(doc.length()>0) {
    			ASToken = doc.substring(doc.indexOf("<ASToken>")+("<ASToken>").length(), doc.indexOf("</ASToken>"));
    		}
        	Log.i("","Recived:".concat(ASToken).toString());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ASToken;
		
	}
	
    public static DesUserOfficeSign buildUserOfficeSign(String userName,String password,String userMail) {
    	DesUserOfficeSign ds = new DesUserOfficeSign();
    	//平台编码
        String ASID = Constants.ASID + Constants.OfficeID;
        //密钥
        String SecretKey = Constants.SecretKey;
        //加密向量
        String IVS = Constants.IVS;
        //时间戳
        String TimeStamp = DateUtil.getDateTime();
//        String userNameValue = userMail + "," + userName;
        String userSign = userMail + "|" + password + "|" + TimeStamp;
        
        String officeSign = ASID + SecretKey + TimeStamp;
        try {
        	//将UserSign进行加密
			userSign = DESedeUtil.encrypt(userSign, SecretKey, IVS);
	        //将OfficeSign进行加密
			officeSign = DESedeUtil.encrypt(officeSign, SecretKey, IVS);
            ds.setOfficeSign(officeSign);
            ds.setUserSign(userSign);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ds;
    }
    
	   //用户注册 ,登录
	public static UserResponseResult userRegister(String userName,String password,String userMail,String serviceType) {
		//平台编码
        String ASID = Constants.ASID + Constants.OfficeID;
        //时间戳
        String TimeStamp = DateUtil.getDateTime();
        System.out.println("userName="+userName+"password="+password+"userMail:"+userMail);
		DesUserOfficeSign ds = buildUserOfficeSign(userName,password,userMail);
		
		userSign = ds.getUserSign();
		OfficeSign	= ds.getOfficeSign();
		
		String url = "http://coa.airnews.com/ASMemberCenter.asmx";
        StringBuffer sb =  new StringBuffer("");
	    sb.append("<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>")
	    .append("  <soap:Body>")
	    .append("     <GetAuthorize xmlns='http://COA.airnew.com'>")
	    .append("      <ASID>" + ASID + "</ASID>")
	    .append("      <TimeStamp>" + TimeStamp + "</TimeStamp>")
	    .append("      <OfficeSign>" + OfficeSign + "</OfficeSign>")
	    .append("      <UserSign>" + userSign + "</UserSign>")
	    .append("      <ServiceType>" + serviceType + "</ServiceType>")
	    .append("      <Return_URL></Return_URL>")
	    .append("    </GetAuthorize>")
	    .append("  </soap:Body>")
	    .append("</soap:Envelope>");
        System.out.println(sb.toString());
        
        String s = BaseAccessor.connectURL(url, sb.toString());
        
        UserResponseResult result = new UserResponseResult();
        
        String ASToken = "";
        String userId = "";
        String userNameResponse = "";
        String reCode = "";
        String message = "";
        try {
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
        	System.out.println("doc="+doc);
    		if(doc.length()>0) {
    			reCode = doc.substring(doc.indexOf("<Result>")+("<Result>").length(), doc.indexOf("</Result>"));
    			if(!"0".equals(reCode)){
    			message = doc.substring(doc.indexOf("<ErrorDescription>")+("<ErrorDescription>").length(), doc.indexOf("</ErrorDescription>"));
    			} else {
    			ASToken = doc.substring(doc.indexOf("<ASToken>")+("<ASToken>").length(), doc.indexOf("</ASToken>"));
    			userId = doc.substring(doc.indexOf("<UserID>")+("<UserID>").length(), doc.indexOf("</UserID>"));
    			userNameResponse = doc.substring(doc.indexOf("<UserName>")+("<UserName>").length(), doc.indexOf("</UserName>"));
    			}
    			result.ASToken = ASToken;
    			result.UserID = userId;
    			result.UserName = userNameResponse; 
    			result.ErrorDescription = message;
    			result.Result = reCode;
    		}
        	Log.i("userRegister",result.ASToken + " " + result.UserName + " " + userId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
		
	}
	
	   //即时支付发起
	public static AirEXPaymentResult airEXPayment (String userIdLogin,String password,String asToken,String payOrders,String price,String flightDetail,String ticketType) {
		
		Log.i("airEXPayment userIdLogin",userIdLogin + " password:" + password + " asToken:" + asToken + " payOrders:" + payOrders);
		//平台编码
        String ASID = Constants.ASID + Constants.OfficeID;
        //时间戳
        String TimeStamp = DateUtil.getDateTime();
		DesUserOfficeSign ds = buildDesUserOfficeSign(userIdLogin,password);
		
		userSign = ds.getUserSign();
		OfficeSign	= ds.getOfficeSign();
		
		String url = "http://asp.airnews.com/ASPayCenter.asmx";
        
		RequestCreditCard reCardPay = new RequestCreditCard();
		reCardPay.setAsID(ASID);
		reCardPay.setAsToken(asToken);
		reCardPay.setOfficeSign(OfficeSign);
		reCardPay.setUserSign(userSign);
		reCardPay.setTimeStamp(TimeStamp);
		reCardPay.setPPPType("PTYPE_ALIPAY");
		reCardPay.setServiceType("CHECK_WITH_ALIXPAY");
		
		String subject = "双程机票";
		if(ticketType.equals("0")){
			subject = "单程机票";
		}
		reCardPay.setSubject(subject);
		reCardPay.setPayOrders(payOrders);
		reCardPay.setDescription(flightDetail);
		reCardPay.setPrice(price);//price
		reCardPay.setRoyaltyNo("");
		
        Log.i("pay", reCardPay.getRequestData());
        String s = BaseAccessor.connectURL(url, reCardPay.getRequestData());
        
        AirEXPaymentResult result = null;
        
        String PostInfo = "";
        String reCode = "";
        String message = "";
        try {
        	
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
        	//构建XmlPullParserFactory   
			XmlPullParserFactory pullParserFactory = XmlPullParserFactory.newInstance();   
			//获取XmlPullParser的实例   
			XmlPullParser xmlPullParser = pullParserFactory.newPullParser();   
			//设置输入流  xml文件装载器   
			xmlPullParser.setInput(new StringReader(doc)); 
			int eventType=xmlPullParser.getEventType(); 
			
			System.out.println("doc="+doc);
			
			while (eventType != XmlPullParser.END_DOCUMENT) {
				String nodeName=xmlPullParser.getName(); 
				switch (eventType) {
					case XmlPullParser.START_DOCUMENT://文档开始事件,可以进行数据初始化处理
						break;
					case XmlPullParser.START_TAG://开始元素事件
						if (nodeName.equalsIgnoreCase("AirEXPaymentResult")) {
							result = new AirEXPaymentResult();
						}
						if (nodeName.equalsIgnoreCase("Result") && result != null) {
							result.Result = xmlPullParser.nextText();
						}
						if (nodeName.equalsIgnoreCase("ErrorDescription") && result != null) {
							result.ErrorDescription = xmlPullParser.nextText();
						}
						if (nodeName.equalsIgnoreCase("PostInfo") && result != null) {
							result.PostInfo = xmlPullParser.nextText();
							result.PostInfo = result.PostInfo.replace("&amp;", "&"); 
						}
						break;
					case XmlPullParser.END_TAG://结束元素事件
						break;
					}
					eventType = xmlPullParser.next();
				}
			
			
			if(result.Result.equals("-36000") && result.PostInfo!=null && !"".equals(result.PostInfo)){
				CabinPolicy cabinPolicy = new CabinPolicy();
				String cabStr = result.PostInfo;
				cabinPolicy.ASPolicyID = cabStr.substring(cabStr.indexOf("<ASPolicyID>")+("<ASPolicyID>").length(), cabStr.indexOf("</ASPolicyID>"));
				cabinPolicy.Rebate = cabStr.substring(cabStr.indexOf("<Rebate>")+("<Rebate>").length(), cabStr.indexOf("</Rebate>"));
				cabinPolicy.Price = cabStr.substring(cabStr.indexOf("<Price>")+("<Price>").length(), cabStr.indexOf("</Price>"));
				cabinPolicy.IBEPolicyID = cabStr.substring(cabStr.indexOf("<IBEPolicyID>")+("<IBEPolicyID>").length(), cabStr.indexOf("</IBEPolicyID>"));
				cabinPolicy.TripType = cabStr.substring(cabStr.indexOf("<TripType>")+("<TripType>").length(), cabStr.indexOf("</TripType>"));
				cabinPolicy.TicketType = cabStr.substring(cabStr.indexOf("<TicketType>")+("<TicketType>").length(), cabStr.indexOf("</TicketType>"));
				cabinPolicy.PolicyRule = cabStr.substring(cabStr.indexOf("<PolicyRule>")+("<PolicyRule>").length(), cabStr.indexOf("</PolicyRule>"));
				cabinPolicy.Others = cabStr.substring(cabStr.indexOf("<Others>")+("<Others>").length(), cabStr.indexOf("</Others>"));
				cabinPolicy.Z = cabStr.substring(cabStr.indexOf("<Z>")+("<Z>").length(), cabStr.indexOf("</Z>"));
				cabinPolicy.Y = cabStr.substring(cabStr.indexOf("<Y>")+("<Y>").length(), cabStr.indexOf("</Y>"));
				result.cabinPolicy = cabinPolicy;
			}
			
//			CabinPolicy cabinPolicy = new CabinPolicy();
//			cabinPolicy.ASPolicyID = "3332323";
//			cabinPolicy.Rebate = "323";
//			cabinPolicy.Price = "2343.21";
//			cabinPolicy.IBEPolicyID = "323";
//			cabinPolicy.TripType = "0";
//			cabinPolicy.TicketType = "0";
//			cabinPolicy.PolicyRule = "";
//			cabinPolicy.Others = "";
//			cabinPolicy.Z = "";
//			cabinPolicy.Y = "";
//			result.cabinPolicy = cabinPolicy;
			
        	Log.i("airEXPayment,result.PostInfo=",result.PostInfo + ";result.Result=" + result.Result + ";result.ErrorDescription=" + result.ErrorDescription);
        } catch(MalformedURLException e1) {
			e1.printStackTrace();
		} catch(XmlPullParserException e2) {
			e2.printStackTrace();
		} catch(IOException e3) {
			e3.printStackTrace();
		}  
		return result;
		
	}
	
	public static String controlMileagerInfo(List<MileagerInfo> mileagerInfoList,String asToken,String userIdLogin,String userPwd) {
		//平台编码
        String ASID = Constants.ASID + Constants.OfficeID;
        //时间戳
        String TimeStamp = DateUtil.getDateTime();
        
        String operateType = "insert";
        
		DesUserOfficeSign ds = buildDesUserOfficeSign(userIdLogin,userPwd);
		
		userSign = ds.getUserSign();
		OfficeSign	= ds.getOfficeSign();
		
		String url = "http://coa.airnews.com/ASMemberCenter.asmx";
		
		RequestMileagerInfo rminfo = new RequestMileagerInfo();
		rminfo.asID = ASID;
		rminfo.userSign = userSign;
		rminfo.officeSign = OfficeSign;
		rminfo.operateType = operateType;
		rminfo.asToken = asToken;
		rminfo.timeStamp = TimeStamp;
		String xml = rminfo.getRequestData(mileagerInfoList);
		Log.i("controlMileagerInfo","xml:".concat(xml).toString());
		String s = BaseAccessor.connectURL(url, xml);
		Log.i("controlMileagerInfo","s:".concat(s).toString());
        String result = "";
        try {
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
        	Log.i("controlMileagerInfo","doc:".concat(doc).toString());
//    		if(doc.length()>0) {
//    			result = doc.substring(doc.indexOf("<ASToken>")+("<ASToken>").length(), doc.indexOf("</ASToken>"));
//    		}
        	Log.i("","Recived:".concat(result).toString());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
		
	}
      //订单查询
	public static OrderInfoResult searchOrderInfo(Context c, SearchOrder searchOrder,String userIdLogin,String userPwd) {
		Log.i("searchOrderInfo", "searchOrderInfo start.");
		long startTime = System.currentTimeMillis();
		// 指定WebService的命名空间和调用的方法名  
		final String METHOD_NAME = "GetOrderInfo";
		String nameSpace = "http://asoc.airnews.com/";
		final String SOAP_ACTION = nameSpace + METHOD_NAME;
		final String req_url = "http://asoc.airnews.com/ASOrderV1.asmx";
		
       // 指定WebService的命名空间和调用的方法名  
       SoapObject rpc = new SoapObject(nameSpace, METHOD_NAME);  
 
       DesUserOfficeSign ds = buildDesUserOfficeSign(userIdLogin,userPwd);
       userSign = ds.getUserSign();
       OfficeSign	= ds.getOfficeSign();
       
       rpc.addProperty("ASID", Constants.ASID + Constants.OfficeID);
       rpc.addProperty("ASPriority", 0);
       rpc.addProperty("TimeStamp", DateUtil.getDateTime());
       rpc.addProperty("UserSign", userSign);
       rpc.addProperty("OfficeSign", OfficeSign);
       rpc.addProperty("PNR", "");//?
       rpc.addProperty("IBETransactionID", "");//?
       rpc.addProperty("IBEOrderID", "");//?
       rpc.addProperty("IDNO", "");//?
		
       rpc.addProperty("OrderNo", searchOrder.OrderNo);
       rpc.addProperty("Status", searchOrder.OrderStatus);
       rpc.addProperty("PassagerName", searchOrder.PassagerName);
       rpc.addProperty("OrderTimeStart", searchOrder.StartOrderTime);
       rpc.addProperty("OrderTimeEnd", searchOrder.EndOrderTime);
       rpc.addProperty("TicketNo", searchOrder.TicketNo);
       
       Log.i("searchOrderInfo", "ASID:" + Constants.ASID);
       Log.i("searchOrderInfo", "ASPriority:" + 0);
       Log.i("searchOrderInfo", "TimeStamp:" + DateUtil.getDateTime());
       Log.i("searchOrderInfo", "UserSign:" + userSign);
       Log.i("searchOrderInfo", "OfficeSign:" + OfficeSign);
       Log.i("searchOrderInfo", "OrderNo:" + searchOrder.OrderNo);
       Log.i("searchOrderInfo", "OrderStatus:"+searchOrder.OrderStatus);
       Log.i("searchOrderInfo", "PassagerName:"+searchOrder.PassagerName);
       Log.i("searchOrderInfo", "OrderTimeStart:"+searchOrder.StartOrderTime);
       Log.i("searchOrderInfo", "OrderTimeEnd:"+searchOrder.EndOrderTime);
       Log.i("searchOrderInfo", "TicketNo:"+searchOrder.TicketNo);
       
       // 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本  
       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);  
 
       envelope.bodyOut = rpc;  
       // 设置是否调用的是dotNet开发的WebService  
       envelope.dotNet = true;  
       // 等价于envelope.bodyOut = rpc;  
       envelope.setOutputSoapObject(rpc);  
 
       HttpTransportSE transport = new HttpTransportSE(req_url);  
 
       try {  
           // 调用WebService  
           transport.call(SOAP_ACTION, envelope);  
       } catch (Exception e) {  
           e.printStackTrace();  
       }  
       
       // 获取返回的数据  
       OrderInfoResult orderInfoResult = new OrderInfoResult();
       try{
    	   SoapObject result = (SoapObject)envelope.bodyIn;  
    	   
    	   System.out.println("完成查询!共用时[" + (System.currentTimeMillis() - startTime)/1000 + "秒]");
           if (result != null) {
               // 获取返回的结果  
               //解析返回结果
               orderInfoResult = parseOrderResult(result);
           }
       }catch(Exception e){
    	   e.printStackTrace();
    	   orderInfoResult.Ret_Msg = "查询失败，没有您查询的结果。";
    	   orderInfoResult.Ret_Code = "-30007";
       }
       
       return orderInfoResult;
	}
	
	//解析返回的结果
	private static OrderInfoResult parseOrderResult(SoapObject result) {
		OrderInfoResult orderInfoResult;
		
		if (result == null) {
			orderInfoResult = null;
		} else {
			orderInfoResult = new OrderInfoResult();
			
			//解析返回对象
			int propertyCount=result.getPropertyCount();
			for(int i=0;i<propertyCount;i++) {
				SoapObject orderResultObj =(SoapObject)result.getProperty(i);
				orderInfoResult.Ret_Code = orderResultObj.getProperty("Result").toString();
				orderInfoResult.Ret_Msg = orderResultObj.getProperty("ErrorDescription").toString();
				//成功返回
				if (orderResultObj.getProperty("Result").toString().equals("0")) {
					//解析订单
					SoapObject orderListObj =(SoapObject)orderResultObj.getProperty("OrderInfosV1");
					int orderCount=orderListObj.getPropertyCount();
					List<OrderInfo> orderInfos = new ArrayList<OrderInfo>();
					for (int j =0; j < orderCount; j ++ ) {
						SoapObject orderObj  = (SoapObject)orderListObj.getProperty(j);
						OrderInfo orderInfo = new OrderInfo();
						orderInfo.OrderNo = getPropertyAsStringFromByTry(orderObj,"OrderNo");
						orderInfo.Trade_No = getPropertyAsStringFromByTry(orderObj,"Trade_No");
						orderInfo.Trade_State = getPropertyAsStringFromByTry(orderObj,"Trade_Status");
						orderInfo.Trade_Info = getPropertyAsStringFromByTry(orderObj,"Trade_Info");
						orderInfo.OfficeID = getPropertyAsStringFromByTry(orderObj,"OfficeID");
						orderInfo.OfficeType = getPropertyAsStringFromByTry(orderObj,"OfficeType");
						orderInfo.UserId = getPropertyAsStringFromByTry(orderObj,"UserID");
						orderInfo.UserType = getPropertyAsStringFromByTry(orderObj,"UserType");
						orderInfo.TotalAmount = getPropertyAsStringFromByTry(orderObj,"TotalAmount");
						orderInfo.Status = getPropertyAsStringFromByTry(orderObj,"Status");
						orderInfo.Sysop = getPropertyAsStringFromByTry(orderObj,"Sysop");
						orderInfo.ModifyTime = getPropertyAsStringFromByTry(orderObj,"ModifyTime");
						orderInfo.CreateTime = getPropertyAsStringFromByTry(orderObj,"CreateTime");
						
						try{
							//解析订单内的机票
							SoapObject flightTicketListObj =(SoapObject)orderObj.getProperty("TicketOrdersV1");
							int flightTicketCount=flightTicketListObj.getPropertyCount();
							for (int k = 0; k < flightTicketCount; k ++) {
								SoapObject flightTicketObj  = (SoapObject)flightTicketListObj.getProperty(k);
								FlightOrder flightOrder = new FlightOrder();
								
								flightOrder.OrderNo = getPropertyAsStringFromByTry(flightTicketObj, "OrderNo");
								flightOrder.TicketOrderNo = getPropertyAsStringFromByTry(flightTicketObj, "TicketOrderNo");
								flightOrder.Course = getPropertyAsStringFromByTry(flightTicketObj, "Course");
								flightOrder.TripType = getPropertyAsStringFromByTry(flightTicketObj, "TripType");
								flightOrder.FlightID = getPropertyAsStringFromByTry(flightTicketObj, "FlightID");
								flightOrder.Cabin = getPropertyAsStringFromByTry(flightTicketObj, "Cabin");
								flightOrder.TicketType = getPropertyAsStringFromByTry(flightTicketObj, "TicketType");
								flightOrder.Price = getPropertyAsStringFromByTry(flightTicketObj, "Price");
								flightOrder.CabinPrice = getPropertyAsStringFromByTry(flightTicketObj, "CabinPrice");
								flightOrder.AirportTax = getPropertyAsStringFromByTry(flightTicketObj, "AirportTax");
								flightOrder.FuelTax = getPropertyAsStringFromByTry(flightTicketObj, "FuelTax");
								flightOrder.Rebate = getPropertyAsStringFromByTry(flightTicketObj, "Rebate");
								flightOrder.TicketNo = getPropertyAsStringFromByTry(flightTicketObj, "TicketNo");
								flightOrder.PNR = getPropertyAsStringFromByTry(flightTicketObj, "PNR");
								flightOrder.Status = getPropertyAsStringFromByTry(flightTicketObj, "Status");
								flightOrder.IBEPolicyID = getPropertyAsStringFromByTry(flightTicketObj, "IBEPolicyID");
								flightOrder.IBEZ = getPropertyAsStringFromByTry(flightTicketObj, "IBEZ");
								flightOrder.IBEY = getPropertyAsStringFromByTry(flightTicketObj, "IBEY");
								flightOrder.IBERestrict =  getPropertyAsStringFromByTry(flightTicketObj, "IBERestrict");
								flightOrder.PassengerIDType = getPropertyAsStringFromByTry(flightTicketObj, "PassengerIDType");
								flightOrder.PassengerName = getPropertyAsStringFromByTry(flightTicketObj, "PassengerName");
								flightOrder.PassengerType = getPropertyAsStringFromByTry(flightTicketObj, "PassengerType");
								flightOrder.PassengerIDNo = getPropertyAsStringFromByTry(flightTicketObj, "PassengerIDNo");
								flightOrder.PassengerBirthday = getPropertyAsStringFromByTry(flightTicketObj, "PassengerBirthday");
								flightOrder.PassengerMobile = getPropertyAsStringFromByTry(flightTicketObj, "PassengerMobile");
								flightOrder.ContactName = getPropertyAsStringFromByTry(flightTicketObj, "ContactName");
								flightOrder.ContactPhone = getPropertyAsStringFromByTry(flightTicketObj, "ContactPhone");
								flightOrder.ContactEmail = getPropertyAsStringFromByTry(flightTicketObj, "ContactEmail");
								flightOrder.PayMethod = getPropertyAsStringFromByTry(flightTicketObj, "PayMethod");
								flightOrder.ItineraryType = getPropertyAsStringFromByTry(flightTicketObj, "ItineraryType");
								
								flightOrder.PostFee = getPropertyAsStringFromByTry(flightTicketObj, "PostFee");
								flightOrder.InvoiceFee = getPropertyAsStringFromByTry(flightTicketObj, "InvoiceFee");
								flightOrder.InsuranceType = getPropertyAsStringFromByTry(flightTicketObj, "InsuranceType");
								flightOrder.InsurancePrice = getPropertyAsStringFromByTry(flightTicketObj, "InsurancePrice");
								flightOrder.Copies = getPropertyAsStringFromByTry(flightTicketObj, "Copies");
								flightOrder.InsuranceAmount = getPropertyAsStringFromByTry(flightTicketObj, "InsuranceAmount");
								
								//解析订单内的行程单详细
								try{
									SoapObject ItineraryInfoObject =(SoapObject)flightTicketObj.getProperty("InvoiceInfo");
										
									if(ItineraryInfoObject.getPropertyCount()!=0){
										ItineraryInfo itineraryInfo = new ItineraryInfo();
//										itineraryInfo.setItineraryOrderNo(ItineraryInfoObject.getProperty("ItineraryOrderNo").toString());
										itineraryInfo.setConsigneeAddress(String.valueOf(ItineraryInfoObject.getProperty("PostalAddress")));
										itineraryInfo.setConsigneeName(String.valueOf(ItineraryInfoObject.getProperty("ConsigneeName")));
										itineraryInfo.setConsigneePhone(String.valueOf(ItineraryInfoObject.getProperty("ConsigneePhone")));
										itineraryInfo.setConsigneeZIP(String.valueOf(ItineraryInfoObject.getProperty("PostCode")));
										flightOrder.ItineraryInfo = itineraryInfo;
									}
								} catch(Exception e){
									flightOrder.ItineraryInfo = null;
								}
								
								//机票航段信息
								SoapObject CourseInfoObject =(SoapObject)flightTicketObj.getProperty("CourseInfo");
								if(CourseInfoObject.getPropertyCount()!=0){
									flightOrder.DepartureTime = CourseInfoObject.getProperty("DepartureTime").toString();
								}
								orderInfo.TicketOrders.add(flightOrder);
							}
						} catch(Exception e){
							continue;
						}
						orderInfos.add(orderInfo);
					}
					orderInfoResult.OrderInfos = orderInfos;
				}
			}
		}
		
		return orderInfoResult;
	}
	/*
	public static boolean updateOrderStatus(Context c, OrderInfo orderInfo, String orderStatus) {
		Log.i("updateOrderStatus", "updateOrderStatus start. OrderNO: " + orderInfo.OrderNo + " orderStatus: " + orderStatus);
		SharedPreferences sp = c.getSharedPreferences("UserInfoB2C", Context.MODE_WORLD_WRITEABLE | Context.MODE_WORLD_READABLE);
		String userIdLogin = sp.getString("userId", null);
		Log.i("OrderSearch userIdLogin", userIdLogin);
       
		String url = "http://asoc.airnews.com/ASOrderV1.asmx";
		StringBuffer sb =  new StringBuffer("");
		sb.append("<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:awp=\"http://awp.airnews.com/\">");
		sb.append("<soap:Header/>")
			.append("  <soap:Body>")
			.append("     <awp:UpdateOrderState>")
			.append("      <awp:ASID>00110001</awp:ASID>")
			.append("      <awp:ASPriority>0</awp:ASPriority>")
			.append("      <awp:TimeStamp>" + DateUtil.getDateTime() + "</awp:TimeStamp>")
			.append("      <awp:OfficeSign>" + OfficeSign + " </awp:OfficeSign>")
			.append("      <awp:UserSign>" + userSign + "</awp:UserSign>")
			.append("      <awp:UserID>" + userIdLogin + "</awp:UserID>")
			.append("      <awp:OrderNO>" + orderInfo.OrderNo + "</awp:OrderNO>")
			.append("      <awp:FOrderNo>" + getFlightOrderNo(orderInfo) + "</awp:FOrderNo>")
			.append("      <awp:IOrderNo>" + getFlightItineraryNo(orderInfo) + "</awp:IOrderNo>")
			.append("      <awp:State>" + orderStatus + "</awp:State>")
			.append("    </awp:UpdateOrderState>")
			.append("  </soap:Body>")
			.append("</soap:Envelope>");
		Log.i("cancelOrder", "Send sms: " + sb.toString());
        
		// 获取返回的数据  
		boolean isSuccess = false;
        try {
        	String s = BaseAccessor.connectURL(url, sb.toString());
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
        	System.out.println("doc="+doc);
    		if(doc.length()>0) {
    			String reCode = doc.substring(doc.indexOf("<Ret_Code>")+("<Ret_Code>").length(), doc.indexOf("</Ret_Code>"));
    			if("0".equals(reCode)){
    				isSuccess = true;
    			}
    		}
		} catch (Exception e) {
			e.printStackTrace();
		}
		  
		Log.i("cancelOrder", "isSuccess: " + isSuccess);
		return isSuccess;
	}
*/
	/**
	 * 未支付才可取消订单
	 * @param c
	 * @param orderNo
	 * @return
	 */
	public static OrderInfoResult applyForCountermand(Context c, String orderNo) {
		Log.i("applyForCountermand", "applyForCountermand start. OrderNO: " + orderNo);
		SharedPreferences sp = c.getSharedPreferences("UserInfoB2C", Context.MODE_WORLD_WRITEABLE | Context.MODE_WORLD_READABLE);
		String userIdLogin = sp.getString("userId", null);
		Log.i("OrderSearch userIdLogin", userIdLogin);
        String ASID = Constants.ASID + Constants.OfficeID;
		String url = "http://asoc.airnews.com/ASOrderV1.asmx";
		StringBuffer sb =  new StringBuffer("");
		sb.append("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:asoc='http://asoc.airnews.com/'>");
		sb.append("<soapenv:Header/>")
			.append("  <soapenv:Body>")
			.append("     <asoc:ApplyForCountermand>")
			.append("      <asoc:ASID>" + ASID + "</asoc:ASID>")
			.append("      <asoc:ASPriority>0</asoc:ASPriority>")
			.append("      <asoc:TimeStamp>" + DateUtil.getDateTime() + "</asoc:TimeStamp>")
			.append("      <asoc:UserSign>" + userSign + "</asoc:UserSign>")
			.append("      <asoc:OfficeSign>" + OfficeSign + " </asoc:OfficeSign>")
			.append("      <asoc:OrderNo>" + orderNo + "</asoc:OrderNo>")
			.append("    </asoc:ApplyForCountermand>")
			.append("  </soapenv:Body>")
			.append("</soapenv:Envelope>");
		Log.i("cancelOrder", "xml: " + sb.toString());
        
		// 获取返回的数据  
		OrderInfoResult orderInfoResult = new OrderInfoResult();
        try {
        	String s = BaseAccessor.connectURL(url, sb.toString());
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
        	System.out.println("doc="+doc);
        	
    		if(doc.length()>0) {
    			String reCode = doc.substring(doc.indexOf("<Result>")+("<Result>").length(), doc.indexOf("</Result>"));
    			orderInfoResult.Ret_Code = reCode;
    			if(!"0".equals(reCode)){
    				String eErrorDescription = doc.substring(doc.indexOf("<ErrorDescription>")+("<ErrorDescription>").length(), doc.indexOf("</ErrorDescription>"));
        			orderInfoResult.Ret_Msg = eErrorDescription;
    			}
    		}
		} catch (Exception e) {
			e.printStackTrace();
		}
		  
		return orderInfoResult;
	}

	/**
	 * 退票接口
	 * @param c
	 * @param orderNo 一站式订单号
	 * @param refundType退订类型	00自愿退票 01非自愿退票
	 * @param applyReason申请退订理由
	 * @param contact退订联系人
	 * @param contactPhone退订联系人电话
	 * @return
	 */
	public static OrderInfoResult applyForRefund(Context c,String orderNo,String refundType,String applyReason,String contact,String contactPhone) {
		Log.i("applyForCountermand", "applyForRefund start. OrderNO: " + orderNo);
		SharedPreferences sp = c.getSharedPreferences("UserInfoB2C", Context.MODE_WORLD_WRITEABLE | Context.MODE_WORLD_READABLE);
		String userIdLogin = sp.getString("userId", null);
		Log.i("OrderSearch userIdLogin", userIdLogin);
		String ASID = Constants.ASID + Constants.OfficeID;
		String url = "http://asoc.airnews.com/ASOrderV1.asmx";
		StringBuffer sb =  new StringBuffer("");
		sb.append("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:asoc='http://asoc.airnews.com/'>");
		sb.append("<soapenv:Header/>")
			.append("  <soapenv:Body>")
			.append("     <asoc:ApplyForRefund>")
			.append("      <asoc:ASID>" + ASID + "</asoc:ASID>")
			.append("      <asoc:ASPriority>0</asoc:ASPriority>")
			.append("      <asoc:TimeStamp>" + DateUtil.getDateTime() + "</asoc:TimeStamp>")
			.append("      <asoc:OfficeSign>" + OfficeSign + " </asoc:OfficeSign>")
			.append("      <asoc:UserSign>" + userSign + "</asoc:UserSign>")
			.append("      <asoc:OrderNo>" + orderNo + "</asoc:OrderNo>")
			.append("      <asoc:RefundType>" + refundType + "</asoc:RefundType>")
			.append("      <asoc:ApplyReason>" + applyReason + "</asoc:ApplyReason>")
			.append("      <asoc:Contact>" + contact + "</asoc:Contact>")
			.append("      <asoc:ContactPhone>" + contactPhone + "</asoc:ContactPhone>")
			.append("    </asoc:ApplyForRefund>")
			.append("  </soapenv:Body>")
			.append("</soapenv:Envelope>");
		Log.i("cancelOrder", "xml: " + sb.toString());
        
		// 获取返回的数据  
		OrderInfoResult orderInfoResult = new OrderInfoResult();
        try {
        	String s = BaseAccessor.connectURL(url, sb.toString());
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
        	System.out.println("doc="+doc);
        	
    		if(doc.length()>0) {
    			String reCode = doc.substring(doc.indexOf("<Result>")+("<Result>").length(), doc.indexOf("</Result>"));
    			orderInfoResult.Ret_Code = reCode;
    			if(!"0".equals(reCode)){
    				String eErrorDescription = doc.substring(doc.indexOf("<ErrorDescription>")+("<ErrorDescription>").length(), doc.indexOf("</ErrorDescription>"));
        			orderInfoResult.Ret_Msg = eErrorDescription;
    			}
    		}
		} catch (Exception e) {
			e.printStackTrace();
		}
		  
		return orderInfoResult;
	}
	
	/**
	 * 申请退款接口
	 * @param c
	 * @param orderNo
	 * @return
	 */
	public static OrderInfoResult applyForReturnAmount (Context c, String orderNo) {
		Log.i("applyForCountermand", "applyForReturnAmount start. OrderNO: " + orderNo);
		SharedPreferences sp = c.getSharedPreferences("UserInfoB2C", Context.MODE_WORLD_WRITEABLE | Context.MODE_WORLD_READABLE);
		String userIdLogin = sp.getString("userId", null);
		Log.i("OrderSearch userIdLogin", userIdLogin);
        String ASID = Constants.ASID + Constants.OfficeID;
		String url = "http://asoc.airnews.com/ASOrderV1.asmx";
		StringBuffer sb =  new StringBuffer("");
		sb.append("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:asoc='http://asoc.airnews.com/'>");
		sb.append("<soapenv:Header/>")
			.append("  <soapenv:Body>")
			.append("     <asoc:ApplyForReturnAmount>")
			.append("      <asoc:ASID>" + ASID + "</asoc:ASID>")
			.append("      <asoc:ASPriority>0</asoc:ASPriority>")
			.append("      <asoc:TimeStamp>" + DateUtil.getDateTime() + "</asoc:TimeStamp>")
			.append("      <asoc:OfficeSign>" + OfficeSign + " </asoc:OfficeSign>")
			.append("      <asoc:UserSign>" + userSign + "</asoc:UserSign>")
			.append("      <asoc:OrderNo>" + orderNo + "</asoc:OrderNo>")
			.append("    </asoc:ApplyForReturnAmount>")
			.append("  </soapenv:Body>")
			.append("</soapenv:Envelope>");
		Log.i("ApplyForReturnAmount", "xml: " + sb.toString());
        
		// 获取返回的数据  
		OrderInfoResult orderInfoResult = new OrderInfoResult();
        try {
        	String s = BaseAccessor.connectURL(url, sb.toString());
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
        	System.out.println("doc="+doc);
        	
    		if(doc.length()>0) {
    			String reCode = doc.substring(doc.indexOf("<Result>")+("<Result>").length(), doc.indexOf("</Result>"));
    			orderInfoResult.Ret_Code = reCode;
    			if(!"0".equals(reCode)){
    				String eErrorDescription = doc.substring(doc.indexOf("<ErrorDescription>")+("<ErrorDescription>").length(), doc.indexOf("</ErrorDescription>"));
        			orderInfoResult.Ret_Msg = eErrorDescription;
    			}
    		}
		} catch (Exception e) {
			e.printStackTrace();
		}
		  
		return orderInfoResult;
	}

	/**
	 * 申请废票接口
	 * @param c
	 * @param orderNo机票订单号
	 * @param PNRNo申请前票号航段旅客所在的PNR
	 * @param tickets如果1个以上票号，票号之间用分号相隔
	 * @return
	 */
	public static OrderInfoResult applyForVoidTicket (Context c, String orderNo,String PNRNo,String tickets) {
		Log.i("applyForCountermand", "ApplyForVoidTicket start. OrderNO: " + orderNo);
		SharedPreferences sp = c.getSharedPreferences("UserInfoB2C", Context.MODE_WORLD_WRITEABLE | Context.MODE_WORLD_READABLE);
		String userIdLogin = sp.getString("userId", null);
		Log.i("OrderSearch userIdLogin", userIdLogin);
        String ASID = Constants.ASID + Constants.OfficeID;
		String url = "http://asoc.airnews.com/ASOrderV1.asmx";
		StringBuffer sb =  new StringBuffer("");
		sb.append("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:asoc='http://asoc.airnews.com/'>");
		sb.append("<soapenv:Header/>")
			.append("  <soapenv:Body>")
			.append("     <asoc:ApplyForVoidTicket>")
			.append("      <asoc:ASID>" + ASID + "</asoc:ASID>")
			.append("      <asoc:ASPriority>0</asoc:ASPriority>")
			.append("      <asoc:TimeStamp>" + DateUtil.getDateTime() + "</asoc:TimeStamp>")
			.append("      <asoc:OfficeSign>" + OfficeSign + " </asoc:OfficeSign>")
			.append("      <asoc:UserSign>" + userSign + "</asoc:UserSign>")
			.append("      <asoc:OrderNo>" + orderNo + "</asoc:OrderNo>")
			.append("      <asoc:PNRNo>" + PNRNo + "</asoc:PNRNo>")
			.append("      <asoc:Tickets>" + tickets + "</asoc:Tickets>")
			.append("    </asoc:ApplyForVoidTicket>")
			.append("  </soapenv:Body>")
			.append("</soapenv:Envelope>");
		Log.i("ApplyForVoidTicket", "xml: " + sb.toString());
        
		// 获取返回的数据  
		OrderInfoResult orderInfoResult = new OrderInfoResult();
        try {
        	String s = BaseAccessor.connectURL(url, sb.toString());
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
        	System.out.println("doc="+doc);
        	
    		if(doc.length()>0) {
    			String reCode = doc.substring(doc.indexOf("<Result>")+("<Result>").length(), doc.indexOf("</Result>"));
    			orderInfoResult.Ret_Code = reCode;
    			if(!"0".equals(reCode)){
//    				String eErrorDescription = doc.substring(doc.indexOf("<ErrorDescription>")+("<ErrorDescription>").length(), doc.indexOf("</ErrorDescription>"));
        			orderInfoResult.Ret_Msg ="废票提交失败，请重新提交或拨打客服电话：4000-555-767";
    			}
    		}
		} catch (Exception e) {
			e.printStackTrace();
		}
		  
		return orderInfoResult;
	}

	/**
	 * 修改乘客证件号码接口
	 * @param c
	 * @param orderNo 机票订单号
	 * @param passengerName 乘客姓名
	 * @param newPassengerIDNo 乘客新证件号码
	 * @return
	 */
	public static OrderInfoResult modifyPassengerIDNo (Context c, String orderNo, String passengerName, String newPassengerIDNo) {
		SharedPreferences sp = c.getSharedPreferences("UserInfoB2C", Context.MODE_WORLD_WRITEABLE | Context.MODE_WORLD_READABLE);
		String userIdLogin = sp.getString("userId", null);
		Log.i("modifyPassengerIDNo userIdLogin", userIdLogin);
        String ASID = Constants.ASID + Constants.OfficeID;
		String url = "http://asoc.airnews.com/ASOrderV1.asmx";
		StringBuffer sb =  new StringBuffer("");
		sb.append("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:asoc='http://asoc.airnews.com/'>");
		sb.append("<soapenv:Header/>")
			.append("  <soapenv:Body>")
			.append("     <asoc:ModifyPassengerIDNo>")
			.append("      <asoc:ASID>" + ASID + "</asoc:ASID>")
			.append("      <asoc:ASPriority>0</asoc:ASPriority>")
			.append("      <asoc:TimeStamp>" + DateUtil.getDateTime() + "</asoc:TimeStamp>")
			.append("      <asoc:OfficeSign>" + OfficeSign + " </asoc:OfficeSign>")
			.append("      <asoc:UserSign>" + userSign + "</asoc:UserSign>")
			.append("      <asoc:OrderNo>" + orderNo + "</asoc:OrderNo>")
			.append("      <asoc:PassengerName>" + passengerName + "</asoc:PassengerName>")
			.append("      <asoc:NewPassengerIDNo>" + newPassengerIDNo + "</asoc:NewPassengerIDNo>")
			.append("    </asoc:ModifyPassengerIDNo>")
			.append("  </soapenv:Body>")
			.append("</soapenv:Envelope>");
		Log.i("modifyPassengerIDNo", "xml: " + sb.toString());
        
		// 获取返回的数据  
		OrderInfoResult orderInfoResult = new OrderInfoResult();
        try {
        	String s = BaseAccessor.connectURL(url, sb.toString());
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
        	System.out.println("doc="+doc);
        	
    		if(doc.length()>0) {
    			String reCode = doc.substring(doc.indexOf("<Result>")+("<Result>").length(), doc.indexOf("</Result>"));
    			orderInfoResult.Ret_Code = reCode;
    			if(!"0".equals(reCode)){
    				String eErrorDescription = doc.substring(doc.indexOf("<ErrorDescription>")+("<ErrorDescription>").length(), doc.indexOf("</ErrorDescription>"));
        			orderInfoResult.Ret_Msg = eErrorDescription;
    			}
    		}
		} catch (Exception e) {
			e.printStackTrace();
		}
		  
		return orderInfoResult;
	}
	
	/**
	 * 机票申请改期
	 * @param c
	 * @param orderNo 机票订单号
	 * @param changeDateData改期申请数据
	 * @param applyReason
	 * @param contact
	 * @param contactPhone
	 * @return
	 */
	public static OrderInfoResult changeDateApply  (Context c, String orderNo, ChangeDateData changeDateData, String applyReason, String contact, String contactPhone) {
		SharedPreferences sp = c.getSharedPreferences("UserInfoB2C", Context.MODE_WORLD_WRITEABLE | Context.MODE_WORLD_READABLE);
		String userIdLogin = sp.getString("userId", null);
		Log.i("changeDateApply userIdLogin", userIdLogin);
        String ASID = Constants.ASID + Constants.OfficeID;
		String url = "http://asoc.airnews.com/ASOrderV1.asmx";
		StringBuffer sb =  new StringBuffer("");
		sb.append("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:asoc='http://asoc.airnews.com/'>");
		sb.append("<soapenv:Header/>")
			.append("  <soapenv:Body>")
			.append("     <asoc:ChangeDateApply>")
			.append("      <asoc:ASID>" + ASID + "</asoc:ASID>")
			.append("      <asoc:ASPriority>0</asoc:ASPriority>")
			.append("      <asoc:TimeStamp>" + DateUtil.getDateTime() + "</asoc:TimeStamp>")
			.append("      <asoc:OfficeSign>" + OfficeSign + " </asoc:OfficeSign>")
			.append("      <asoc:UserSign>" + userSign + "</asoc:UserSign>")
			.append("      <asoc:OrderNo>" + orderNo + "</asoc:OrderNo>")
			.append("      <asoc:ChangeDateData>")
			.append("           <asoc:AirTicketNo>" + changeDateData.airTicketNo + "</asoc:AirTicketNo>")
			.append("           <asoc:AirFlightNo>" + changeDateData.airFlightNo + "</asoc:AirFlightNo>")
			.append("           <asoc:PsgName>" + changeDateData.pagName + "</asoc:PsgName>")
			.append("           <asoc:TicketChangeDate>" + changeDateData.ticketChangeDate + "</asoc:TicketChangeDate>")
			.append("           <asoc:NewAirFlightNo>" + changeDateData.newAirFlightNo + "</asoc:NewAirFlightNo>")
			.append("      </asoc:ChangeDateData>")
			.append("      <asoc:ApplyReason>" + applyReason + "</asoc:ApplyReason>")
			.append("      <asoc:Contact>" + contact + "</asoc:Contact>")
			.append("      <asoc:ContactPhone>" + contactPhone + "</asoc:ContactPhone>")
			.append("    </asoc:ChangeDateApply>")
			.append("  </soapenv:Body>")
			.append("</soapenv:Envelope>");
		Log.i("ChangeDateApply", "xml: " + sb.toString());
        
		// 获取返回的数据  
		OrderInfoResult orderInfoResult = new OrderInfoResult();
        try {
        	String s = BaseAccessor.connectURL(url, sb.toString());
        	String doc = new String(s.getBytes("UTF-8"), System.getProperty("file.encoding"));
        	System.out.println("doc="+doc);
        	
    		if(doc.length()>0) {
    			String reCode = doc.substring(doc.indexOf("<Result>")+("<Result>").length(), doc.indexOf("</Result>"));
    			orderInfoResult.Ret_Code = reCode;
    			if(!"0".equals(reCode)){
    				String eErrorDescription = doc.substring(doc.indexOf("<ErrorDescription>")+("<ErrorDescription>").length(), doc.indexOf("</ErrorDescription>"));
        			orderInfoResult.Ret_Msg = eErrorDescription;
    			}
    		}
		} catch (Exception e) {
			e.printStackTrace();
		}
		  
		return orderInfoResult;
	}
	
	
	private static String getPropertyAsStringFromByTry(SoapObject soapObject, String propertyName) {
		String value;
		try {
			value = soapObject.getPropertyAsString(propertyName);
		} catch (Exception e) {
			value = "";
		}
		return value;
	}
	
	/**
	 * 自动更新接口，带升级描述
	 * @param context
	 * @return
	 * @throws JSONException
	 */
	public static  VersionInfo updateSoftVersionDetail(Context context) throws JSONException{
		String urlString = "http://m.jpfanli.com/b2c/jsonUpdateVersion.json";
		//[{"verName":1.0.1,"verCode":2}]  
		HashMap<String, String> params = new HashMap<String, String>();
//		String jsonString = BaseAccessor.deRequest(context,urlString, params);
		String jsonString = BaseAccessor.readHttpJson(urlString);
		System.out.println("jsonString="+jsonString);
		VersionInfo vinfo = new VersionInfo();
		JSONArray array = new JSONArray(jsonString); 
        if (array.length() > 0) {  
            JSONObject obj = array.getJSONObject(0);
            try {  
            	vinfo.setVerCode(Integer.parseInt(obj.getString("verCode")));
            	vinfo.setVerName(obj.getString("verName"));
            } catch (Exception e) {  
                vinfo.setVerCode(-1);
            	vinfo.setVerName("");
            }  
        }  
        return vinfo;  
	}
	
	
}
